import os
import sys

def build(infile, outfile):
    command_str = "pyrcc5 {} -o {}".format(infile, outfile)
    result = os.popen(command_str).read()
    print(result)

def _create_outfile_full_path(infile):
    infile_path, infile_full_name = os.path.split(infile)
    infile_file_name, infile_file_ext = os.path.splitext(infile_full_name)

    outfile_file_name = "_rc".join([infile_file_name, ".py"])
    outfile = os.path.join(infile_path, outfile_file_name)
    return outfile

if __name__ == '__main__':
    if len(sys.argv) >= 2:
        infile = sys.argv[1]
        outfile = _create_outfile_full_path(infile)

        build(infile, outfile)
    else:
        print("参数不足")